//
//  LoginViewController.m
//  XingMei
//
//  Created by 钱金军 on 2019/3/20.
//  Copyright © 2019年 钱金军. All rights reserved.
//

#import "LoginViewController.h"
#import "FilesHeader.h"

@interface LoginViewController ()

@end

@implementation LoginViewController
{
    UITextField *passwordText;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setLoginView];
    [self setLoginButton];
    
}


- (void)setLoginView{
    UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(0, Height_NavBar+50, KScreenWidth, 50)];
    title.text = @"型美";
    title.textColor = rgba(255, 116, 2, 1);
    title.textAlignment = NSTextAlignmentCenter;
    title.font = [UIFont fontWithName:ZhongDeng size:54];
    [self.view addSubview:title];
    
    /** 登录账户 */
    UIImageView *accountLeftView = [[UIImageView alloc] initWithFrame:CGRectMake(50, title.bottom + 60, 15, 15)];
    accountLeftView.image = [UIImage imageNamed:@"register_icon_1"];
    [self.view addSubview:accountLeftView];
    
    UILabel *accountLabel = [[UILabel alloc] initWithFrame:CGRectMake(accountLeftView.right + 7, accountLeftView.top, 70, 15)];
    accountLabel.text = @"登录账户";
    accountLabel.textColor = rgba(51, 51, 51, 1);
    accountLabel.textAlignment = NSTextAlignmentCenter;
    accountLabel.font = [UIFont fontWithName:ZhongDeng size:14];
    [self.view addSubview:accountLabel];
    
    UITextField *accountText = [[UITextField alloc] initWithFrame:CGRectMake(accountLabel.right + 10, accountLabel.top, KScreenWidth-accountLabel.right-70, accountLabel.frame.size.height)];
    accountText.layer.borderColor = [UIColor clearColor].CGColor;
    accountText.font = [UIFont fontWithName:ZhongDeng size:14];
    [self.view addSubview:accountText];
    
    UIView *accountLine = [[UIView alloc] initWithFrame:CGRectMake(accountLabel.right, accountText.bottom + 15, KScreenWidth-accountLabel.right-50, 1)];
    accountLine.backgroundColor = rgba(232, 232, 232, 1);
    [self.view addSubview:accountLine];
    
    /** 登录密码 */
    UIImageView *passwordLeftView = [[UIImageView alloc] initWithFrame:CGRectMake(50, accountLeftView.bottom + 35, 15, 15)];
    passwordLeftView.image = [UIImage imageNamed:@"register_icon_2"];
    [self.view addSubview:passwordLeftView];
    
    UILabel *passwordLabel = [[UILabel alloc] initWithFrame:CGRectMake(passwordLeftView.right + 7, passwordLeftView.top, 70, 15)];
    passwordLabel.text = @"登录密码";
    passwordLabel.textColor = rgba(51, 51, 51, 1);
    passwordLabel.textAlignment = NSTextAlignmentCenter;
    passwordLabel.font = [UIFont fontWithName:ZhongDeng size:14];
    [self.view addSubview:passwordLabel];
    
    passwordText = [[UITextField alloc] initWithFrame:CGRectMake(passwordLabel.right + 10, passwordLabel.top, KScreenWidth-passwordLabel.right-70, passwordLabel.frame.size.height)];
    passwordText.layer.borderColor = [UIColor clearColor].CGColor;
    passwordText.font = [UIFont fontWithName:ZhongDeng size:14];
    [self.view addSubview:passwordText];
    
    UIView *passwordLine = [[UIView alloc] initWithFrame:CGRectMake(passwordLabel.right, passwordText.bottom + 15, KScreenWidth-passwordLabel.right-50, 1)];
    passwordLine.backgroundColor = rgba(232, 232, 232, 1);
    [self.view addSubview:passwordLine];
}


- (void)setLoginButton{
    /** 登录 */
    UIButton *loginBtn = [[UIButton alloc] initWithFrame:CGRectMake(48, passwordText.bottom + 55, KScreenWidth-96, 45)];
    [loginBtn setBackgroundImage:[UIImage imageNamed:@"register_img_10"] forState:UIControlStateNormal];
    [loginBtn setTitle:@"登录" forState:UIControlStateNormal];
    [loginBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    loginBtn.layer.cornerRadius = 22;
    [self.view addSubview:loginBtn];
    [loginBtn addTarget:self action:@selector(clickLogin) forControlEvents:UIControlEventTouchUpInside];
    
    /** 忘记密码 */
    UIButton *forgetPassword = [[UIButton alloc] initWithFrame:CGRectMake(loginBtn.left + 15, loginBtn.bottom + 17, 70, 12)];
    [forgetPassword setTitle:@"忘记密码？" forState:UIControlStateNormal];
    [forgetPassword setTitleColor:rgba(255, 116, 2, 1) forState:UIControlStateNormal];
    forgetPassword.titleLabel.font = [UIFont fontWithName:ZhongDeng size:12];
    [self.view addSubview:forgetPassword];
    [forgetPassword addTarget:self action:@selector(clickForgetPassword) forControlEvents:UIControlEventTouchUpInside];
    
    /** 注册 */
    UIButton *registerBtn = [[UIButton alloc] initWithFrame:CGRectMake(loginBtn.right - 50, forgetPassword.top, 35, forgetPassword.frame.size.height)];
    [registerBtn setTitle:@"注册" forState:UIControlStateNormal];
    [registerBtn setTitleColor:rgba(51, 51, 51, 1) forState:UIControlStateNormal];
    registerBtn.titleLabel.font = [UIFont fontWithName:ZhongDeng size:12];
    [self.view addSubview:registerBtn];
    [registerBtn addTarget:self action:@selector(clickRegister) forControlEvents:UIControlEventTouchUpInside];
}

#pragma mark 点击登录
- (void)clickLogin{
    BaseViewController *rootVc = [NSClassFromString(@"DGTabBarViewController") new];
    self.view.window.rootViewController = rootVc;
}

#pragma mark 点击忘记密码
- (void)clickForgetPassword{
    ForgotPasswordViewController *forgotPassword = [[ForgotPasswordViewController alloc] init];
    forgotPassword.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    [self presentViewController:forgotPassword animated:YES completion:nil];
}

#pragma mark 点击注册
- (void)clickRegister{
    RegisterViewController *zhuCe = [[RegisterViewController alloc] init];
    zhuCe.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    [self presentViewController:zhuCe animated:YES completion:nil];
}

@end
